﻿using System;
using System.Collections.Generic;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using KPIS.GERP.GBMS.IBLL;
using KPIS.GERP.GBMS.MODEL;
using KPIS.GERP.GBMS.DAL;
using KPIS.GERP.GBMS.DALFactory;

namespace KPIS.GERP.GBMS.BLL
{
    public class StrategyVisionBLL : IStrategyVisionBLL
    {
        private static readonly IStrategyVisionDAL dal = DataAccess.CreateStrategyVision();

        public StrategyVisionBLL()
        {

        }

        public void Insert(string code, string name, string descr)
        {
            StrategyVisionInfo strategyInfo = new StrategyVisionInfo(-1, code, name, descr, SystemInfo._ActiveRecordStatus, new UserRecordInfo(1, null));

            int chkError = dal.Insert(strategyInfo);

            if (chkError == 0)
            {
                // Error
            }
        }

        public void Update(int seq, string code, string name, string descr)
        {
            StrategyVisionInfo strategyInfo = new StrategyVisionInfo(seq, code, name, descr, SystemInfo._ActiveRecordStatus, new UserRecordInfo(null, 1));

            int chkError = dal.Update(strategyInfo);

            if (chkError == 0)
            {
                // Error
            }
        }

        public void Delete(int seq)
        {
            int chkError = dal.Delete(seq);
        }

        public IList<StrategyVisionInfo> Search(int seq)
        {
            return Search(seq, "", "", "");
        }

        public IList<StrategyVisionInfo> Search(int seq, string code, string name, string descr)
        {
            StrategyVisionInfo strategyInfo = new StrategyVisionInfo(seq, code, name, descr, SystemInfo._ActiveRecordStatus, null);

            return dal.Search(strategyInfo);
        }
        public bool CheckDuplicateCode(string code, string currentSeq)
        {
            return dal.CheckDuplicateCode(code, currentSeq);
        }
    }
}
